package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.WmsProducts;
import com.ruoyi.system.service.IWmsProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;

/**
 * 商品基础信息Controller
 *
 * @author ruoyi
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/system/wmsProducts")
public class WmsProductsController extends BaseController
{
    @Autowired
    private IWmsProductsService wmsProductsService;

    /**
     * 查询商品基础信息列表
     */
    @SaCheckPermission("system:wmsProducts:list")
    @GetMapping("/list")
    public TableDataInfo<WmsProducts> list(WmsProducts wmsProducts, PageQuery pageQuery)
    {
        return wmsProductsService.selectWmsProductsList(wmsProducts,pageQuery);
    }

    /**
     * 导出商品基础信息列表
     */
    /*@SaCheckPermission("system:wmsProducts:export")
    @Log(title = "商品基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsProducts wmsProducts)
    {
        List<WmsProducts> list = wmsProductsService.selectWmsProductsList(wmsProducts);
        ExcelUtil<WmsProducts> util = new ExcelUtil<WmsProducts>(WmsProducts.class);
        util.exportExcel(response, list, "商品基础信息数据");
    }*/

    /**
     * 获取商品基础信息详细信息
     */
    @SaCheckPermission("system:wmsProducts:query")
    @GetMapping(value = "/{id}")
    public R<WmsProducts> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(wmsProductsService.selectWmsProductsById(id));
    }

    /**
     * 新增商品基础信息
     */
    @SaCheckPermission("system:wmsProducts:add")
    @Log(title = "商品基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsProducts wmsProducts) throws Exception {
        return toAjax(wmsProductsService.insertWmsProducts(wmsProducts));
    }

    /**
     * 修改商品基础信息
     */
    @SaCheckPermission("system:wmsProducts:edit")
    @Log(title = "商品基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsProducts wmsProducts)
    {
        return toAjax(wmsProductsService.updateWmsProducts(wmsProducts));
    }

    /**
     * 删除商品基础信息
     */
    @SaCheckPermission("system:wmsProducts:remove")
    @Log(title = "商品基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsProductsService.deleteWmsProductsByIds(ids));
    }
}
